Polygons 

__________________________________________
Calculations with Polygons  *404*

__________________________________________
OpenPoly  *404*

Output names:   poly

Output types:   PolyHandle

Description:   Returns a handle to a new polygon and tells QuickDraw to start saving a polygon definition as specified by calls to line-drawing routines. While a polygon is open, all calls to Line and LineTo affect the outline of the polygon.  Only the line endpoints affect the polygon definition; the pen mode, pattern, and size do not affect it.

__________________________________________
ClosePoly  *404*

Description:   Tells QuickDraw to stop saving the definition of the currently open polygon.  Only one ClosePoly should be performed for every OpenPoly.

__________________________________________
KillPoly  *404*

Input names:   poly

Input types:   PolyHandle

Description:   Releases the memory occupied by the given polygon.

__________________________________________
OffsetPoly  *405*

Input names:   poly, dh, dv

Input types:   PolyHandle, integer, integer

Description:   Moves the polygon on the coordinate plane, a distance of dh horizontally and dv vertically.  This doesn’t affect the screen unless a routine is subsequently called to draw the polygon.

__________________________________________
Graphic Operations on Polygons

The following routines, with the exception of FramePoly, do not alter the pen location. 

__________________________________________
FramePoly  *405*

Input names:   poly

Input types:   PolyHandle

Description:   Plays back the line-drawing routine calls that define the given polygon, using the current grafPort’s pen pattern, mode, and size.

__________________________________________
PaintPoly  *405*

Input names:   poly

Input types:   PolyHandle

Description:   Paints the specified polygon with the current grafPort’s pen pattern and pen mode.

__________________________________________
ErasePoly  *405*

Input names:   poly

Input types:   PolyHandle

Description:   Paints the specified polygon with the current grafPort’s background pattern bkPat.

__________________________________________
InvertPoly  *405*

Input names:   poly

Input types:   PolyHandle

Description:   Inverts the pixels enclosed by the specified polygon:    every white pixel becomes black and every black pixel becomes white.

__________________________________________
FillPoly  *406*

Input names:   poly, pat

Input types:   PolyHandle, Pattern

Description:   Fills the specified polygon with the given pattern.

__________________________________________
Points 

__________________________________________
AddPt  *406*

Input names:   srcPt, dstPt

Input types:   Point, Point

Output names:   dstPt

Output types:   Point 

Description:   Adds the coordinates of srcPt to the coordinates of dstPt and returns the result in dstPt.

__________________________________________
SubPt  *406*

Input names:   srcPt, dstPt

Input types:   Point, Point

Output names:   dstPt

Output types:   Point 

Description:   Subtracts the coordinates of srcPt from the coordinates of dstPoint and returns the result in dstPt.

__________________________________________
SetPt  *406*

Input names:   pt, h, v

Input types:   Point, integer, integer

Output names:   pt

Output types:   Point 

Description:   Assigns the two given coordinates to aPoint.

__________________________________________
EqualPt  *407*

Input names:   pt1, pt2 

Input types:   Point, Point 

Output names:   Boolean

Output types:   boolean 

Description:   Compares the two given points and returns TRUE if they are equal or FALSE if not.

__________________________________________
LocalToGlobal  *407*

Input names:   pt 

Input types:   Point 

Output names:   pt

Output types:   Point 

Description:   Converts the given point from the current grafPort’s local coordinate system into a global coordinate system with the origin (0, 0) at the top left corner of the port’s bit image (such as the screen). This global point can then be compared to other global points, or be changed into the local coordinates of another grafPort.  Since a rectangle is defined by two points, a rectangle can be converted into global coordinates by performing two LocalToGlobal calls. A rectangle, region, or polygon can also be converted into global coordinates by calling OffsetRect, OffsetRgn, or OffsetPoly.

__________________________________________
GlobalToLocal  *407*

Input names:   pt 

Input types:   Point 

Output names:   pt

Output types:   Point 

Description:   Takes a point expressed in global coordinates (with the top left corner of the bit image as coordinate (0,0)) and converts it into the local coordinates of the current grafPort.  The global point can be obtained with the LocalToGlobal call (see above).

__________________________________________
DeltaPoint  *408*

Input names:   pt1, pt2 

Input types:   Point, Point 

Output names:   LongInt

Output types:   LongInt

Description:   Subtracts the coordinates of pt2 from the coordinates of pt1.  The high-order word of the result is the difference of the vertical coordinates and the low-order word is the difference of the horizontal coordinates.

__________________________________________
Resources 

__________________________________________
Opening and Closing Resource Files 

__________________________________________
CreateResFile  *408*

Input names:   fileName 

Input types:   string 

Description:   Creates a resource file containing no resource data.  If there’s no file with the given name, it also creates an empty data fork for the file.

__________________________________________
OpenResFile  *408*

Input names:   fileName 

Input types:   string 

Output names:   referenceNum 

Output types:   integer 

Description:   Opens the resource file having the given name and makes it the current resource file.  It also reads the resource map from the file into memory and returns a reference number for the file.  If the resource file is already open, it doesn’t make it the current resource file; it simply returns the reference number.

__________________________________________
CloseResFile  *409*

Input names:   refNum 

Input types:   integer 

Description:   Given the reference number of a resource file, CloseResFile does the following:  

 o
updates the resource file by calling UpdateResFile

 o
for each resource in the resource file, releases the 
   memory it occupies by calling ReleaseResource

 o
releases the memory occupied by the resource map

 o
closes the resource file.

 A CloseResFile of every open resource file (except the system resource file) is done automatically when the application terminates.  So CloseResFile need only be called if the resource file is to be closed before the application terminates.

__________________________________________
Checking for Errors

__________________________________________
ResError  *409*

Output names:   Integer 

Output types:   integer 

Description:   Returns a result code identifying the error, if any.  If no error occurred, it returns the result code (see Inside Macintosh).

__________________________________________
Setting the Current Resource File

__________________________________________
CurResFile  *409*

Output names:   refNum 

Output types:   integer 

Description:   Returns the reference number of the current resource file.

__________________________________________
HomeResFile  *410*

Input names:   theResource 

Input types:   Handle 

Output names:   Integer 

Output types:   integer 

Description:   Given a handle to a resource, returns the reference number of the current resource file containing that resource.

__________________________________________
UseResFile  *410*

Input names:   refNum 

Input types:   integer 

Description:   Given the reference number of a resource file, UseResFile sets the current resource file to that file. 

__________________________________________
Accessing Resources

__________________________________________
CountResources  *410*

Input names:   theType 

Input types:   ResType 

Output names:   totalNum 

Output types:   integer 

Description:   Returns the total number of resources of the given type in all open resource files.

__________________________________________
Count1Resources  *410*

Input names:   theType 

Input types:   ResType 

Output names:   totalNum 

Output types:   integer 

Description:   Returns the total number of resources of the given type in the current resource file only.

__________________________________________
GetIndResource  *411*

Input names:   theType, Integer 

Input types:   ResType , integer

Output names:   aResource 

Output types:   Handle 

Description:   Given a resource type (theType) and an index ranging from 1 to CountResources (see CountResources, above), GetIndResource returns a handle to that resource.

__________________________________________
Get1IndResource  *411*

Input names:   theType, Integer 

Input types:   ResType , integer

Output names:   aResource 

Output types:   Handle 

Description:   Given a resource type (theType) and an index ranging from 1 to CountResources (see Count1Resources, above), Get1IndResource returns a handle to that resource from the current resource file only.

__________________________________________
GetResource  *411*

Input names:   theType, theID 

Input types:   ResType , integer

Output names:   Handle 

Output types:   Handle 

Description:   Given a resource type and ID, returns a handle to that resource (or NULL if not found), reading the resource data into memory if necessary.

__________________________________________
Get1Resource  *411*

Input names:   theType, theID 

Input types:   ResType , integer

Output names:   Handle 

Output types:   Handle 

Description:   Same as GetResource, except that it searches the current resource file only.

__________________________________________
GetNamedResource  *412*

Input names:   theType, name 

Input types:   ResType , string

Output names:   Handle 

Output types:   Handle 

Description:   Given a resource type and name, returns a handle to that resource (or NULL if not found), reading the resource data into memory if necessary.

__________________________________________
Get1NamedResource  *412*

Input names:   theType, name 

Input types:   ResType , string

Output names:   Handle 

Output types:   Handle 

Description:   Same as GetNamedResource except that it searches the current resource file only.

__________________________________________
Getting Resource Information

__________________________________________
UniqueID  *412*

Input names:   theType 

Input types:   ResType 

Output names:   Integer

Output types:   integer 

Description:   Returns an ID number greater than 0 and that isn’t currently assigned to any resource of the given type in any open resource file.

__________________________________________
Unique1ID  *413*

Input names:   theType 

Input types:   ResType 

Output names:   Integer

Output types:   integer 

Description:   Same as UniqueID except that the number returned is unique only for resources in the current resource file.

__________________________________________
GetResInfo  *413*

Input names:   theResource, theID, theType, name 

Input types:   Handle, integer, ResType, string

Output names:   theID, theType, name 

Output types:   integer, ResType, string

Description:   Given a handle to a resource, GetResInfo returns the ID number, type, and name of the resource.

__________________________________________
SizeResource  *413*

Input names:   theResource

Input types:   Handle 

Output names:   Integer

Output types:   integer

Description:   Given a handle to a resource, SizeResource returns the size in bytes of the resource in the resource file.